import { IntersectionType } from "@nestjs/swagger";
import { PagerDto } from "~/common/dto/pager.dto";
import { ApiProperty } from '@nestjs/swagger';
import { IsEnum, IsOptional, IsString } from 'class-validator';
import { PointsGoodsExchangeStatus } from './points-goods-exchange.entity';

export class FindPointsGoodsExchangeListDto extends IntersectionType(PagerDto) {

}

export class PointsGoodsExchangePageDto extends PagerDto {
  @ApiProperty({ description: '兑换状态', enum: PointsGoodsExchangeStatus, required: false })
  @IsOptional()
  @IsEnum(PointsGoodsExchangeStatus)
  status?: PointsGoodsExchangeStatus;

  @ApiProperty({ description: '兑换标题（模糊查询）', required: false })
  @IsOptional()
  @IsString()
  title?: string;

  @ApiProperty({ description: '用户ID', required: false })
  @IsOptional()
  userId?: number;

  @ApiProperty({ description: '商品ID', required: false })
  @IsOptional()
  goodsId?: number;
}

export class PointsGoodsExchangeResponseDto {
  @ApiProperty({ description: '兑换记录ID' })
  id: number;

  @ApiProperty({ description: '兑换标题' })
  title: string;

  @ApiProperty({ description: '商品图片链接' })
  imageUrl: string;

  @ApiProperty({ description: '兑换状态', enum: PointsGoodsExchangeStatus })
  status: PointsGoodsExchangeStatus;

  @ApiProperty({ description: '创建时间' })
  createdAt: Date;

  @ApiProperty({ description: '更新时间' })
  updatedAt: Date;

  @ApiProperty({ description: '商品信息', required: false })
  goods?: {
    id: number;
    name: string;
    price: number;
    image: string;
    description: string;
    stock: number;
  };

  @ApiProperty({ description: '用户信息', required: false })
  user?: {
    id: number;
    username: string;
    email: string;
    wechat?: {
      id: number;
      nickname: string;
      phone: string;
      avatar: string;
      healthPoints: number;
    };
  };
}

export class PointsGoodsExchangeExportDto {
  @ApiProperty({ description: '兑换状态', enum: PointsGoodsExchangeStatus, required: false })
  @IsOptional()
  @IsEnum(PointsGoodsExchangeStatus)
  status?: PointsGoodsExchangeStatus;

  @ApiProperty({ description: '兑换标题（模糊查询）', required: false })
  @IsOptional()
  @IsString()
  title?: string;

  @ApiProperty({ description: '用户ID', required: false })
  @IsOptional()
  userId?: number;

  @ApiProperty({ description: '商品ID', required: false })
  @IsOptional()
  goodsId?: number;
}